package de.fhkl.gatav.ut.bernd_0;

import java.io.IOException;

import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class Bernd_0 extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        final MediaPlayer mPlayer;
        mPlayer = MediaPlayer.create(this, R.raw.berndsaahhh);
        mPlayer.setLooping(false);        
        
        Button playButton = (Button) findViewById(R.id.play_button);
        Button pauseButton = (Button) findViewById(R.id.pause_button);
        Button stopButton = (Button) findViewById(R.id.stop_button);
        
        playButton.setOnClickListener(new View.OnClickListener() {
        	public void onClick(View v) {
        		mPlayer.start();
        	}
        } );
        
        pauseButton.setOnClickListener(new View.OnClickListener() {
        	public void onClick(View v) {
        		mPlayer.pause();
        	}
        } );
        
        stopButton.setOnClickListener(new View.OnClickListener() {
        	public void onClick(View v) {
        		mPlayer.stop();
        		try {
        			mPlayer.prepare();
        		} catch (IllegalStateException e) {
        			// TODO Auto-generated catch block
        			e.printStackTrace();
        		} catch (IOException e) {
        			// TODO Auto-generated catch block
        			e.printStackTrace();
        		}
        	}
        } );
    }
}